<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>TODO supply a title</title>
    </head>
    <body>
        <div> 
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                            xmlns:ui="http://java.sun.com/jsf/facelets"
                            xmlns:h="http://java.sun.com/jsf/html"
                            xmlns:rich="http://richfaces.org/rich"
                            xmlns:a4j="http://richfaces.org/a4j"
                            xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                            xmlns:f="http://java.sun.com/jsf/core">
                <h:form id="emp">
                    <rich:panel header="预算追加明细编制" styleClass="content-hight">
                        <h:panelGrid columns="5" id="firstGroup" style=" text-align: left">
                            <h:outputLabel value="年度："/>
                            <h:selectOneMenu value="#{budgetAddEditGovBean.iyear}" style="width:90px;text-align: left">
                                <f:selectItem itemValue="" itemLabel="-请选择-"/>
                                <f:selectItems value="#{budgetAddEditGovBean.yearli}"/>
                                <a4j:ajax event="change" render="@this,button,add"/>
                            </h:selectOneMenu>
                            <h:outputLabel value="采购预算资金性质："/>
                            <h:selectOneMenu value="#{budgetAddEditGovBean.quality}"
                                             style="width:130px;">
                                <f:selectItem itemValue="" itemLabel="-请选择-"/>
                                <f:selectItem itemValue="0" itemLabel="基本支出"/>
                                <f:selectItem itemValue="1" itemLabel="项目支出"/>
                                <a4j:ajax event="change" render="@this,button,projName,add,err,projNameLabel,editGrid"
                                          listener="#{budgetAddEditGovBean.changeListener}" />
                            </h:selectOneMenu>
                            <a4j:commandButton id="button" value="确定" action="#{budgetAddEditGovBean.query}"
                                               onclick="this.disabled = 'true'"
                                               render="tolbar,err,tableGroup,editGrid"
                                               execute="@this"/>
                        </h:panelGrid>
                        <rich:toolbar id="tolbar">
                            <rich:toolbarGroup>
                                <a4j:commandButton id="add" value="新建" action="#{budgetAddEditGovBean.add}"
                                                   execute="@this" render="tolbar,editGrid,err"
                                                   disabled="#{empty budgetAddEditGovBean.iyear and empty budgetAddEditGovBean.quality}"/>
                                <a4j:commandButton value="修改" action="#{budgetAddEditGovBean.update}"
                                                   execute="@this" render="tolbar,editGrid"
                                                   disabled="#{budgetAddEditGovBean.addOrUpdate
                                                               or budgetAddEditGovBean.base == null
                                                               or empty budgetAddEditGovBean.base.number
                                                               or empty budgetAddEditGovBean.detail.number
                                                               or budgetAddEditGovBean.detail.status =='1'
                                                               or budgetAddEditGovBean.detail.status =='3'
                                                       }"/>
                                <a4j:commandButton value="删除" action="#{budgetAddEditGovBean.delete}"
                                                   execute="@form" render="tolbar,editGrid,tableGroup,err"
                                                   disabled="#{budgetAddEditGovBean.addOrUpdate
                                                               or budgetAddEditGovBean.base eq null
                                                               or empty budgetAddEditGovBean.base.number
                                                               or empty budgetAddEditGovBean.detail.number
                                                               or budgetAddEditGovBean.detail.status =='1'
                                                               or budgetAddEditGovBean.detail.status =='3'}"
                                                   onclick="this.disabled = 'true'"/>
                                <a4j:commandButton value="保存" action="#{budgetAddEditGovBean.checkSave}"
                                                   execute="@form" render="tolbar,err,editGrid,tableGroup"
                                                   disabled="#{!budgetAddEditGovBean.editStatus
                                                               or budgetAddEditGovBean.base == null
                                                               or empty budgetAddEditGovBean.base.number
                                                               or budgetAddEditGovBean.detail.status =='1'
                                                               or budgetAddEditGovBean.detail.status =='3'}"
                                                   onclick="this.disabled = 'true'"/>
                                <a4j:commandButton value="取消" action="#{budgetAddEditGovBean.cancel}"
                                                   execute="@this" render="tolbar,editGrid"
                                                   disabled="#{budgetAddEditGovBean.base == null
                                                               or empty budgetAddEditGovBean.base.number
                                                               or budgetAddEditGovBean.detail.status =='1'
                                                               or budgetAddEditGovBean.detail.status =='3'}"/>
                                <a4j:commandButton value="提交" action="#{budgetAddEditGovBean.submitFor}"
                                                   execute="@this" render="tolbar,err,editGrid,tableGroup"
                                                   disabled="#{budgetAddEditGovBean.base == null
                                                               or empty budgetAddEditGovBean.base.number
                                                               or empty budgetAddEditGovBean.detail.number
                                                               or budgetAddEditGovBean.addOrUpdate
                                                               or budgetAddEditGovBean.detail.status =='1'
                                                               or budgetAddEditGovBean.detail.status =='3'
                                                               or budgetAddEditGovBean.editStatus}"/>
                                <a4j:commandButton value="撤消" action="#{budgetAddEditGovBean.canclFor}"
                                                   execute="@this" render="tolbar,err,editGrid,tableGroup"
                                                   disabled="#{budgetAddEditGovBean.base == null
                                                               or empty budgetAddEditGovBean.base.number
                                                               or empty budgetAddEditGovBean.detail.number
                                                               or budgetAddEditGovBean.addOrUpdate
                                                               or budgetAddEditGovBean.detail.status =='0'
                                                               or budgetAddEditGovBean.detail.status =='3'}"/>
                            </rich:toolbarGroup>
                        </rich:toolbar>
                        <h:outputLabel id="err" value="#{queryBean.err.errtip}" style="color:red"/>
                        <rich:notifyMessage stayTime="5000"/>
                        <h:panelGrid id="editGrid" columns="4" width="100%" style="text-align:left;">
                            <h:outputLabel value="编号："/>
                            <h:inputText value="#{budgetAddEditGovBean.detail.number}" disabled="true"/>
                            <h:outputLabel id="projNameLabel" value="项目：" rendered="#{budgetAddEditGovBean.quality == '1'}"/>
                            <h:inputText id="projName" value="#{budgetAddEditGovBean.detail.project.finName}"
                                         rendered="#{budgetAddEditGovBean.quality == '1'}"
                                         disabled="#{!budgetAddEditGovBean.editStatus or budgetAddEditGovBean.quality == '0'}"
                                         onclick="#{rich:component('projectPanel')}.show()"/>
                            <h:outputLabel value="预算类别："/>
                            <h:selectOneMenu  value="#{budgetAddEditGovBean.detail.planWay}" disabled="#{!budgetAddEditGovBean.editStatus}"
                                              style="width:130px;">
                                <f:selectItem itemValue="公共预算" itemLabel="公共预算"/>
                            </h:selectOneMenu>
                            <h:outputLabel value="追加日期："/>
                            <h:panelGroup>
                                <rich:calendar disabled="true"
                                               value="#{budgetAddEditGovBean.detail.editDate}"
                                               locale="zh_CN"
                                               popup="true"
                                               datePattern="yyyy-MM-dd"
                                               showApplyButton="true"
                                               style="width:200px"/>
                            </h:panelGroup>

                            <h:outputLabel value="处室："/>
                            <h:inputText id="officeName" value="#{budgetAddEditGovBean.detail.officeName}"
                                         disabled="#{!budgetAddEditGovBean.editStatus}"
                                         onclick="#{rich:component('officePanel')}.show();"/>

                            <h:outputLabel value="品目："/>
                            <h:inputText id="cateName" value="#{budgetAddEditGovBean.detail.cate.name}"
                                         disabled="#{!budgetAddEditGovBean.editStatus}"
                                         onclick="#{rich:component('catePanel')}.show()"/>
                            <h:outputLabel value="规格型号："/>
                            <h:inputText id="model" value="#{budgetAddEditGovBean.detail.model}" disabled="#{!budgetAddEditGovBean.editStatus}"/>

                            <h:outputLabel value="计量单位："/>
                            <h:inputText id="unitId" value="#{budgetAddEditGovBean.detail.cate.unit}" disabled="#{!budgetAddEditGovBean.editStatus}"/>
                            <h:outputLabel value="采购数量："/>
                            <h:panelGroup>
                                <h:inputText id="countId" value="#{budgetAddEditGovBean.detail.cate.count}" disabled="#{!budgetAddEditGovBean.editStatus}"
                                             style="text-align: right;"  validatorMessage="数值不能超过9位！">
                                    <f:validateDoubleRange maximum="999999999"/>
                                    <a4j:ajax event="blur" execute="@this" render="@this,messageCount"/>
                                    <f:convertNumber type="number" pattern="#,##0"/>
                                </h:inputText>
                                <h:message id="messageCount" for="countId" style="color:red"/>
                            </h:panelGroup>
                            <h:outputLabel value="财政性资金："/>
                            <h:panelGroup>
                                <h:inputText id="financialId" value="#{budgetAddEditGovBean.detail.financial}" disabled="#{!budgetAddEditGovBean.editStatus}"
                                             style="text-align: right" converterMessage="请输入数值!">
                                    <a4j:ajax event="blur" execute="@this" render="@this,messageFinancialId"/>
                                    <f:convertNumber type="number" pattern="#,##0.00"/>
                                </h:inputText>
                                <h:message id="messageFinancialId"  for="financialId" style="color:red" />
                            </h:panelGroup>
                            <h:outputLabel value="其他资金："/>
                            <h:panelGroup>
                                <h:inputText id="otherId" value="#{budgetAddEditGovBean.detail.other}" disabled="#{!budgetAddEditGovBean.editStatus}"
                                             style="text-align: right" converterMessage="请输入数值!">
                                    <a4j:ajax event="blur" execute="@this" render="@this,messageOtherId"/>
                                    <f:convertNumber type="number" pattern="#,##0.00"/>
                                </h:inputText>
                                <h:message id="messageOtherId" for="otherId" style="color:red"/>
                            </h:panelGroup>
                            <h:outputLabel value="组织形式："/>
                            <h:selectOneMenu value="#{budgetAddEditGovBean.detail.organizeForm}" disabled="#{!budgetAddEditGovBean.editStatus}"
                                             style="width:130px;">
                                <f:selectItem itemValue="0" itemLabel="集中采购"/>
                                <f:selectItem itemValue="1" itemLabel="部门集中采购"/>
                                <f:selectItem itemValue="2" itemLabel="分散采购"/>
                            </h:selectOneMenu>
                            <h:outputLabel value="委托集中采购机构："/>
                            <h:inputText value="#{budgetAddEditGovBean.detail.organ}" disabled="true"/>
                            <h:outputLabel value="采购方式："/>
                            <h:selectOneMenu value="#{budgetAddEditGovBean.detail.cateWay}" disabled="#{!budgetAddEditGovBean.editStatus}"
                                             style="width:130px;">
                                <f:selectItem itemValue="0" itemLabel="公开招标"/>
                                <f:selectItem itemValue="1" itemLabel="邀请招标"/>
                                <f:selectItem itemValue="2" itemLabel="竞价性谈判"/>
                                <f:selectItem itemValue="3" itemLabel="单一来源"/>
                                <f:selectItem itemValue="4" itemLabel="询价"/>
                            </h:selectOneMenu>
                            <h:outputLabel value="附信息:" />
                            <h:panelGroup id="append">
                                <h:selectOneMenu value="#{budgetAddEditGovBean.detail.append}"
                                                 disabled="#{!budgetAddEditGovBean.editStatus or budgetAddEditGovBean.selectNameli == null
                                                             or budgetAddEditGovBean.selectNameli.size() ==0}"
                                                 style="width:130px;">
                                    <f:selectItem itemValue="" itemLabel="-请选择-"/>
                                    <f:selectItems value="#{budgetAddEditGovBean.selectNameli}"/>
                                </h:selectOneMenu>
                                <h:outputLabel id="jinggao" value="*品目为计算机、家具、打印机时必须选择该项" style="color:red"/>
                            </h:panelGroup>

                            <h:outputLabel value="备注："/>
                            <h:inputText id="memo" value="#{budgetAddEditGovBean.detail.memo}"
                                         disabled="#{!budgetAddEditGovBean.editStatus}"/>

                        </h:panelGrid>
                        <hr/>
                        <h:panelGroup id="tableGroup">
                            <rich:dataScroller for="editTable" execute="@this" render="tableGroup"/>
                            <div style="width:780px;min-height:200px;overflow:auto;">
                                <rich:dataTable id="editTable" value="#{budgetAddEditGovBean.detailModel}" var="emp"
                                                rowClasses="list-row-odd,list-row-even" rowKeyVar="rowKey"
                                                headerClass="table-header"
                                                noDataLabel="无数据!"
                                                style="width:1500px;margin-bottom: 20px;">
                                    <rich:column>
                                        <f:facet name="header">序号</f:facet>
                                            #{rowKey+1}
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">类别</f:facet>
                                        <a4j:commandLink value="#{emp.planWay}" action="#{budgetAddEditGovBean.selected}" render="editGrid,tolbar,append"/>
                                    </rich:column>
                                    <rich:column rendered="#{budgetAddEditGovBean.quality =='1'}" >
                                        <f:facet name="header">项目</f:facet>
                                        <h:outputText value="#{emp.project.finName}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">编号</f:facet>
                                        <h:outputText value="#{emp.number}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">状态</f:facet>
                                        <h:outputText value="未提交"  rendered="#{emp.status == '0'}"/>
                                        <h:outputText value="已提交等待审核"  rendered="#{emp.status == '1'}" style="color:blue"/>
                                        <h:outputText value="审核通过"  rendered="#{emp.status == '3'}" style="color:green"/>
                                        <h:outputText value="退回修改"  rendered="#{emp.status == '2'}" style="color:red"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">品目</f:facet>
                                        <h:outputText value="#{emp.cate.name}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">计量单位</f:facet>
                                        <h:outputText value="#{emp.cate.unit}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">采购数量</f:facet>
                                        <h:outputText value="#{emp.cate.count}"/>
                                    </rich:column>
                                    <rich:column style="text-align: right;width:120px">
                                        <f:facet name="header">财政性资金</f:facet>
                                        <h:outputText value="#{emp.financial}">
                                            <f:convertNumber type="number" pattern="#,##0.00"/>
                                        </h:outputText>
                                    </rich:column>
                                    <rich:column style="text-align:right;width:120px">
                                        <f:facet name="header">其他资金</f:facet>
                                        <h:outputText value="#{emp.other}">
                                            <f:convertNumber type="number" pattern="#,##0.00"/>
                                        </h:outputText>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">组织形式</f:facet>
                                        <h:outputText value="集中采购" rendered="#{emp.organizeForm == '0'}"/>
                                        <h:outputText value="部门集中采购" rendered="#{emp.organizeForm == '1'}"/>
                                        <h:outputText value="分散采购" rendered="#{emp.organizeForm == '2'}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">委托的集中采购机构</f:facet>
                                        <h:outputText value="#{emp.organ}"/>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">采购方式</f:facet>
                                        <h:outputText value="公开招标" rendered="#{emp.cateWay == '0'}"/>
                                        <h:outputText value="邀请招标" rendered="#{emp.cateWay == '1'}"/>
                                        <h:outputText value="竞争性谈判" rendered="#{emp.cateWay == '2'}"/>
                                        <h:outputText value="单一来源" rendered="#{emp.cateWay == '3'}"/>
                                        <h:outputText value="询价" rendered="#{emp.cateWay == '4'}"/>
                                    </rich:column>


                                    <rich:column style="width:80px;text-align:center">
                                        <f:facet name="header">操作</f:facet>
                                        <a4j:commandLink action="#{showFlowInfoBean.showFlowInfo(emp.id,'1')}"
                                                         oncomplete="#{rich:component('checkInfoPanel')}.show();"
                                                         render="infoPanel">
                                            <h:outputText value="审批信息"/>
                                        </a4j:commandLink>
                                    </rich:column>

                                    <f:facet name="footer"/>
                                </rich:dataTable>
                            </div>
                        </h:panelGroup>
                    </rich:panel>
                </h:form>
                <rich:popupPanel id="catePanel" autosized="true" width="500" height="500">
                    <f:facet name="header">采购类目</f:facet>
                    <f:facet name="controls">
                        <h:outputLink value="#" onclick="#{rich:component('catePanel')}.hide();
                                                       return false;">关闭</h:outputLink>
                    </f:facet>
                    <h:form>
                        <rich:panel>
                            <div style="height:430px;overflow:auto;">
                                <rich:tree value="#{categoryBean.rootNode}" var="idept"
                                           selectionType="ajax" toggleType="client"
                                           selectionChangeListener="#{budgetAddEditGovBean.cateSelected}"
                                           style="width:300px;text-align: left" render="cateName,appenda,append,unitId">
                                    <rich:treeNode rendered="#{idept.data.isEnd eq 0}">
                                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                    </rich:treeNode>
                                    <rich:treeNode rendered="#{idept.data.isEnd eq 1}" onclick="#{rich:component('catePanel')}.hide()">
                                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                    </rich:treeNode>
                                </rich:tree>
                            </div>
                        </rich:panel>
                    </h:form>
                </rich:popupPanel>

                <rich:popupPanel id="projectPanel" autosized="true" width="500" height="500">
                    <f:facet name="header">项目列表</f:facet>
                    <f:facet name="controls">
                        <h:outputLink value="#" onclick="#{rich:component('projectPanel')}.hide();
                                                       return false;">关闭</h:outputLink>
                    </f:facet>
                    <h:form>
                        <rich:panel>
                            <div style="height:430px;overflow:auto;">
                                <rich:dataTable id="editTable" value="#{budgetAddEditGovBean.projModel}" var="emp"
                                                rowClasses="list-row-odd,list-row-even" rowKeyVar="rowKey"
                                                headerClass="table-header"
                                                noDataLabel="无数据!"
                                                style="width:300px;">
                                    <rich:column>
                                        <f:facet name="header">项目代码</f:facet>
                                        <a4j:commandLink  action="#{budgetAddEditGovBean.selectProject}"
                                                          render="projName"
                                                          onclick="#{rich:component('projectPanel')}.hide();">
                                            <h:outputText value="#{emp.finCode}"/>
                                        </a4j:commandLink>
                                    </rich:column>
                                    <rich:column>
                                        <f:facet name="header">项目名称</f:facet>
                                        <h:outputText value="#{emp.finName}"/>
                                    </rich:column>

                                    <f:facet name="footer"/>
                                </rich:dataTable>
                            </div>
                        </rich:panel>
                    </h:form>
                </rich:popupPanel>


                <rich:popupPanel id="checkInfoPanel" autosized="true" width="500" height="500">
                    <f:facet name="header">项目列表</f:facet>
                    <f:facet name="controls">
                        <h:outputLink value="#" onclick="#{rich:component('checkInfoPanel')}.hide();
                                                       return false;">关闭</h:outputLink>
                    </f:facet>
                    <h:form>
                        <rich:panel id="infoPanel">
                            <ui:include src="/page/checkflow/checkInfo.xhtml"/>
                        </rich:panel>
                    </h:form>
                </rich:popupPanel>

                <rich:popupPanel id="officePanel" autosized="true" width="500" height="500">
                    <f:facet name="header">处室</f:facet>
                    <f:facet name="controls">
                        <h:outputLink value="#" onclick="#{rich:component('officePanel')}.hide();
                                                       return false;">关闭</h:outputLink>
                    </f:facet>
                    <h:form>
                        <rich:panel id="officeTree">
                            <div style="height:430px;overflow:auto;">
                                <rich:tree value="#{budgetAddEditGovBean.rootNode}" var="idept"
                                           selectionType="ajax" toggleType="client"
                                           selectionChangeListener="#{budgetAddEditGovBean.treeSelected}"
                                           style="width:300px" render="officeName">
                                    <rich:treeNode rendered="#{idept.data.isEnd eq 0}">
                                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                    </rich:treeNode>
                                    <rich:treeNode rendered="#{idept.data.isEnd eq 1}" onclick="#{rich:component('officePanel')}.hide()">
                                        <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                    </rich:treeNode>
                                </rich:tree>
                            </div>
                        </rich:panel>
                    </h:form>
                </rich:popupPanel>

            </ui:composition>
        </div>
    </body>
</html>
